<template>
  <div class="app-containerA">
    <div class="leftbox">
      <div
        style="
          display: flex;
          flex-direction: column;
          justify-content: space-between;
          width: 486px;
        "
      >
        <div class="fristitem">
          <div style="display: flex; align-items: center">
            <img
              src="@/assets/logo/km.png"
              alt=""
              style="width: 20px; height: 20px; margin-right: 12px"
            />
            <p style="margin-bottom: 0px; font-size: 14px; color: #333">
              培训科目
            </p>
          </div>
          <el-dropdown
            @command="command"
            trigger="click"
            placement="bottom-start"
            class="dropdownBox"
          >
            <span class="el-dropdown-link">
              {{ subjectTitleA }}<i class="el-icon-caret-bottom"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item
                v-for="item in userinfor"
                :key="item.id"
                :command="item"
                :style="{
                  color: subjct == item.subject_id ? '#46a6ff' : '#333',
                }"
              >
                {{ item.subjectTitle }}
              </el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
          <div class="tipsubjet">
            <i
              style="
                display: block;
                height: 16px;
                width: 16px;
                line-height: 16px;
                text-align: center;
                background: #175dff;
                color: #fff;
                border-radius: 50%;
                margin-right: 16px;
              "
            >
              !
            </i>
            多科目学员点击上方科目名称可切换其他科目 ↑
          </div>
        </div>
        <div
          style="
            background: #fff;
            border-radius: 10px;
            height: 127px;
            width: 100%;
            padding: 20px 24px;
          "
        >
          <p style="margin-bottom: 8px; color: #333; font-size: 16px">
            常用功能
          </p>
          <div class="btn_box">
            <el-button
              v-if="
                http.indexOf('qdjsxy') != -1 ||
                http.indexOf('yzza') != -1 ||
                http.indexOf('lyky') != -1 ||
                (http.indexOf('bosheng') != -1 && gz == '燃气从业人员培训')
              "
              type="primary"
              @click="getinvoice"
              >申请发票
            </el-button>
            <el-button
              type="primary"
              @click="
                () => {
                  this.$router.push('/statistics/index');
                }
              "
              >统计</el-button
            >

            <!-- <el-button type="primary">操作指南</el-button> -->
            <el-button
              type="primary"
              @click="openClick"
              v-if="showbtnImg && !gz.includes('企业班组长')"
              >打印证书</el-button
            >
            <el-button
              type="primary"
              @click="TCshowImg = true"
              v-if="http.includes('hongjing')"
              >附件下载</el-button
            >
            <el-button
              v-if="this.initObj.aboutus"
              type="primary"
              @click="studentfont"
              >学员公告</el-button
            >
            <el-button
              v-if="
                http.includes('lyjc') && ['特种作业', '安全管理'].includes(gz)
              "
              type="primary"
              @click="examSubmit"
              >考试报名</el-button
            >
          </div>
        </div>
      </div>
      <div class="lastitem">
        <div style="display: flex; align-items: flex-end">
          <div style="flex: 1">
            <div class="nameAndPick">
              <img v-if="headPicture" :src="headPicture" alt="" />
              <img v-else src="@/assets/logo/logo.png" alt="" />
              <span>{{ nickname }}</span>
            </div>
            <div
              style="
                margin-top: 28px;
                width: 100%;
                display: flex;
                justify-content: space-between;
              "
            >
              <div
                style="
                  width: 206px;
                  height: 81px;
                  background: #175dff;
                  border-radius: 8px;
                  display: flex;
                  align-items: center;
                "
              >
                <div style="margin: 0 16px">
                  <img
                    src="@/assets/littleIcon/mubiao.png"
                    style="height: 28px; width: 28px"
                    alt=""
                  />
                </div>
                <div style="color: #fff">
                  <p>目标学时</p>
                  <div>
                    <span style="font-size: 24px; color: #fff">
                      {{ aim_score }} </span
                    >(学时)
                  </div>
                </div>
              </div>
              <div
                style="
                  width: 206px;
                  height: 81px;
                  background: #36be3d;
                  border-radius: 8px;
                  display: flex;
                  align-items: center;
                "
              >
                <div style="margin: 0 16px">
                  <img
                    src="@/assets/littleIcon/yiwancheng.png"
                    style="height: 28px; width: 28px"
                    alt=""
                  />
                </div>
                <div style="color: #fff">
                  <p>已学学时</p>
                  <div>
                    <span style="font-size: 24px; color: #fff">
                      {{ score_current }} </span
                    >(学时)
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div
            style="
              margin-left: 52px;
              width: 136px;
              height: 136px;
              overflow: hidden;
            "
          >
            <circleProgress :progress="process" :diameter="136">
              <div
                style="
                  width: 100%;
                  height: 100%;
                  display: flex;
                  align-items: center;
                  justify-content: center;
                "
              >
                <div>
                  <p style="text-align: center; font-size: 18px">
                    {{ process }}%
                  </p>
                  <span style="font-size: 12px; color: #333">学习进度</span>
                </div>
              </div>
            </circleProgress>
          </div>
        </div>
        <div
          style="
            display: flex;
            justify-content: space-between;
            margin-top: 26px;
          "
        >
          <div>
            <p style="color: #69718c; font-size: 14px; margin-bottom: 16px">
              模拟练习次数
            </p>
            <div>
              <span style="font-weight: 600; font-size: 24px">
                {{ exam_count }}次
              </span>
            </div>
          </div>
          <div>
            <p style="color: #69718c; font-size: 14px; margin-bottom: 16px">
              学员剩余时间
            </p>
            <div>
              <span style="font-weight: 600; font-size: 24px">
                {{ interval }}
              </span>
            </div>
          </div>
          <div>
            <p style="color: #69718c; font-size: 14px; margin-bottom: 16px">
              开通时间
            </p>
            <div>
              <span style="font-weight: 600; font-size: 24px">
                {{ start_time.split(" ")[0] }}
              </span>
            </div>
          </div>
          <div>
            <p style="color: #69718c; font-size: 14px; margin-bottom: 16px">
              最近登录时间
            </p>
            <div>
              <span style="font-weight: 600; font-size: 24px">
                {{ login_time.split(" ")[0] }}
              </span>
            </div>
          </div>
        </div>
      </div>
      <div class="pickBox">
        <p style="padding-top: 20px; padding-left: 24px">快捷入口</p>
        <div class="bigbox">
          <ul
            class="pickItem"
            @click="
              () => {
                this.$router.push('/practice/index');
              }
            "
            v-if="Jurisdiction.专项练习 == '显示'"
          >
            <li class="pickItemLi">
              <img src="@/assets/littleIcon/zhuanxiang.png" alt="" />
              <span>题库练习</span>
            </li>
          </ul>
          <ul
            class="pickItem"
            @click="
              () => {
                this.$router.push('/simulation/index');
              }
            "
            v-if="Jurisdiction.模拟考试 == '显示'"
          >
            <li class="pickItemLi">
              <img src="@/assets/littleIcon/2.png" alt="" />
              <span>模拟考试</span>
            </li>
          </ul>
          <ul
            class="pickItem"
            @click="
              () => {
                this.$router.push('/simulationzs/index');
              }
            "
            v-if="Jurisdiction.正式考试 == '显示'"
          >
            <li class="pickItemLi">
              <img src="@/assets/littleIcon/zhengshi.png" alt="" />
              <span v-if="http.indexOf('yingji') != -1">模拟练习</span>
              <span v-else>正式考试</span>
            </li>
          </ul>
          <ul
            v-if="showcourseware"
            class="pickItem"
            @click="
              () => {
                this.$router.push('/curriculum/index');
              }
            "
          >
            <li class="pickItemLi">
              <img src="@/assets/littleIcon/kejian.png" alt="" />
              <span>课程学习</span>
            </li>
          </ul>
          <ul
            class="pickItem"
            @click="
              () => {
                this.$router.push('/questionsSearch/index');
              }
            "
            v-if="
              Jurisdictions.试题搜索 &&
              Jurisdictions.试题搜索.模块展示 == '显示'
            "
          >
            <li class="pickItemLi">
              <img src="@/assets/littleIcon/shiti.png" alt="" />
              <span>试题搜索</span>
            </li>
          </ul>
          <ul
            class="pickItem"
            @click="mineError"
            v-if="
              Jurisdictions.错题库 && Jurisdictions.错题库.模块展示 == '显示'
            "
          >
            <li class="pickItemLi">
              <img src="@/assets/littleIcon/3.png" alt="" />
              <span>错题集</span>
            </li>
          </ul>
          <ul
            class="pickItem"
            @click="mineCanlt"
            v-if="
              Jurisdictions.收藏题库 &&
              Jurisdictions.收藏题库.模块展示 == '显示'
            "
          >
            <li class="pickItemLi">
              <img src="@/assets/littleIcon/shoucang.png" alt="" />
              <span>收藏</span>
            </li>
          </ul>
          <ul
            class="pickItem"
            @click="
              () => {
                this.$router.push('/practice/index?titleName=`精选题库`');
              }
            "
            v-if="isShowJX"
          >
            <li class="pickItemLi">
              <img src="@/assets/littleIcon/jx.png" alt="" />
              <span>精选题库</span>
            </li>
          </ul>
          <ul
            class="pickItem"
            @click="baList"
            v-if="http.indexOf('peixun') != -1"
          >
            <li class="pickItemLi">
              <img src="@/assets/littleIcon/tongji.png" alt="" />
              <span>备案登记表</span>
            </li>
          </ul>
          <ul
            class="pickItem"
            @click="openUpload"
            v-if="http.indexOf('peixun') != -1"
          >
            <li class="pickItemLi">
              <img src="@/assets/littleIcon/kaoshijilu.png" alt="" />
              <span>论文上传</span>
            </li>
          </ul>
          <!-- sdtjy  -->
          <ul
            class="pickItem"
            @click="
              () => {
                $refs.evaluate.open();
              }
            "
            v-if="
              (http.includes('sdtjy') ||
                http.includes('jyhc') ||
                http.includes('jtlzy') ||
                http.includes('qiye') ||
                http.includes('kmjd')) &&
              progressVisible
            "
          >
            <li class="pickItemLi">
              <img src="@/assets/littleIcon/pingjia.png" alt="" />
              <span>评价</span>
            </li>
          </ul>
        </div>
      </div>
    </div>
    <div class="rightbox">
      <courseware
        :default="false"
        v-if="showcourseware"
        @clickrow="learnOpen"
      ></courseware>
    </div>
    <modelPDF ref="modelPDF"></modelPDF>
    <modelBA ref="modelBA" @seachLeng="seachLeng"></modelBA>
    <uploadFiles ref="uploadFiles" @seachLeng="seachLeng"></uploadFiles>
    <el-dialog
      title="大培训行业选择"
      :visible.sync="showdio"
      width="25%"
      :show-close="false"
      :close-on-press-escape="false"
      :close-on-click-modal="false"
      class="elDialog"
    >
      <p style="line-height: 1.8; font-size: 16px; font-weight: 600">
        请根据您的所在行业选择对应的行业，并输入上您的所在单位信息。
      </p>
      <el-radio-group
        v-model="radioEdit"
        :style="{ display: 'flex', flexDirection: 'column' }"
      >
        <el-radio style="padding: 5px 0" :label="1092">工贸行业</el-radio>
        <el-radio style="padding: 5px 0" :label="1091">危化行业</el-radio>
        <el-radio style="padding: 5px 0" :label="1093">住房建设行业</el-radio>
        <el-radio style="padding: 5px 0" :label="1094">交通运输</el-radio>
        <el-radio style="padding: 5px 0" :label="1095">矿山行业</el-radio>
        <el-radio style="padding: 5px 0" :label="1096">民用爆破</el-radio>
        <el-radio style="padding: 5px 0" :label="1097">烟花爆竹</el-radio>
      </el-radio-group>
      <el-input
        style="margin-top: 15px; width: 70% !important"
        v-model="company"
        placeholder="请输入您所在的公司或工作单位"
      ></el-input>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="commitEdit">确 定</el-button>
      </span>
    </el-dialog>
    <applyInvoice ref="applyinvoice"></applyInvoice>
    <div
      style="position: absolute; top: 0; left: 0; z-index: -10; width: 100%"
      v-if="Object.keys(inforMi).length != 0"
    >
      <exports :listData="inforMi" v-show="false"></exports>
    </div>
    <el-dialog
      :title="downloadURL ? '图片另存为' : '附件下载'"
      :visible.sync="TCshowImg"
      width="25%"
      :close-on-press-escape="false"
      :close-on-click-modal="false"
      class="elDialog"
      :before-close="
        (done) => {
          (this.downloadURL = ''), done();
        }
      "
    >
      <div v-if="downloadURL">
        <img
          style="width: 100%; position: relative; top: 10%; z-index: 1000000"
          :src="downloadURL"
          alt=""
        />
      </div>
      <div v-else>
        <div class="item" style="background-color: #ddd">
          <p>附件名称</p>
          <div>操作</div>
        </div>
        <div>
          <div class="item border" v-for="(item, index) in list" :key="index">
            <p>{{ item.lebel }}</p>
            <div>
              <van-button
                type="info"
                size="small"
                style="background: rgb(249, 151, 56); border: none"
                @click="downloadFile(item)"
                >下载</van-button
              >
            </div>
          </div>
        </div>
      </div>
    </el-dialog>
    <evaluate v-show="false" ref="evaluate"></evaluate>
  </div>
  <!-- changesubjct -->
</template>

<script>
import applyInvoice from "@/views/pc/applyInvoice.vue";
import { mapGetters } from "vuex";
// import progressA from "./components/progress.vue";
import courseware from "../components/pickv3.vue";
import modelPDF from "@/components/PDF/modelPDF.vue";
import modelBA from "./components/modelBA.vue";
import uploadFiles from "./components/uploadFiles.vue";
import exports from "@/components/exports.vue";
import { downImg } from "@/utils/downloadImg.js";
import { download } from "@/api/download.js";

import { getUserMedia } from "@/permission.js";
import evaluate from "./evaluate";
import circleProgress from "@/components/circleProgress";
import {
  mywrong,
  mycollect,
  getSetting,
  userlearn,
  materialkmlist,
  getQcount,
  changesid,
  updateApply,
} from "@/api/admin.js";
import {
  getsubject_id,
  setsubject_id,
  getsubjectTitle,
  setsubjectTitle,
  setapplyid,
  getapplyid,
  delapplyid,
  setisphoto,
  delisphoto,
  setJurisdiction,
  setGZ,
  getJurisdiction,
  setispay,
  setExectSetting,
  setLearnTime,
  getGender,
  setuserstate,
  getuserstate,
  deluserstate,
  setcurrentInfo,
  getUsername,
  getispay,
} from "@/utils/auth";
export default {
  components: {
    // progressA,
    courseware,
    modelPDF,
    modelBA,
    uploadFiles,
    applyInvoice,
    exports,
    evaluate,
    circleProgress,
  },
  computed: {
    ...mapGetters([
      "userAgent",
      "userinfor",
      "adminUserId",
      "nickname",
      "login_time",
      "Jurisdiction",
      "Jurisdictions",
      "headPicture",
      "initObj",
    ]),
  },
  watch: {
    process(val) {
      if (val == 100) {
        this.progressVisible = true;
      } else {
        this.progressVisible = false;
      }
    },
  },
  data() {
    return {
      gz: "",
      subjct: "",
      subjectTitleA: "",
      progressVisible: false, //学时提醒
      process: 0, //学时百分比
      start_time: "", //开通时间
      exam_count: 0, //考试次数
      interval: "", //天数
      aim_score: 20, //目标学时
      score_current: 20, //学习时长
      cfs: "", //初复审
      title: "您的线上培训学习时长已达到32学时，可以进行考试取证", //学时提醒
      zsIsYes: false,
      listhas: {},
      passNum: 0,
      inforMi: {},
      http:
        process.env.NODE_ENV === "development"
          ? process.env.VUE_APP_BASE_API
          : window.location.href.slice(
              0,
              window.location.href.indexOf("/user")
            ),
      showbtnImg: false, //是否展示证书打印按钮
      dengjiList: {},
      lunwenList: [],
      isShowJX: false,
      radioEdit: "", //修改
      showdio: false,
      company: "",
      TCshowImg: false,
      downloadURL: "",
      list: [],
      showcourseware: true,
    };
  },
  created() {
    delapplyid();
    if (
      JSON.parse(this.initObj.setting) &&
      JSON.parse(this.initObj.setting).downPine
    ) {
      this.showbtnImg =
        JSON.parse(this.initObj.setting).downPine == "是" ? true : false;
    }
    this.subjct =
      getsubject_id() && getsubject_id() != "null"
        ? Number(getsubject_id())
        : this.userinfor[0].subject_id;
    this.subjectTitleA =
      getsubjectTitle() && getsubjectTitle() != "null"
        ? getsubjectTitle()
        : this.userinfor[0].subjectTitle;

    // if (getapplyid()) {
    // } else {
    //   setapplyid(this.userinfor[0].applyid);
    // }
    let isfaceMack = "";
    if (this.initObj.is_face) {
      isfaceMack = JSON.parse(this.initObj.is_face);
    } else {
      isfaceMack = "";
    }
    let oaa = false;
    this.userinfor.map((item) => {
      if (this.subjct == item.subject_id) {
        oaa = true;
      }
    });
    if (!oaa) {
      this.subjct = this.userinfor[0].subject_id;
      this.subjectTitleA = this.userinfor[0].subjectTitle;
    }

    this.userinfor.map(async (item) => {
      if (this.subjct == item.subject_id) {
        setapplyid(item.applyid);
        setsubjectTitle(item.subjectTitle);
        setsubject_id(item.subject_id);
        getQcount({
          subjectid: this.subjct,
          pool: "精选题库",
          applyid: item.applyid,
        }).then((res) => {
          if (res.code == 200) {
            if (res.data.count > 0) {
              this.isShowJX = true;
            } else {
              this.isShowJX = false;
            }
          }
        });
        let exclude_material = item.exclude_material;
        if (exclude_material == "是") {
          this.showcourseware = false;
        } else {
          if (
            this.initObj.exclude_material &&
            this.initObj.exclude_material
              .split(",")
              .indexOf(this.subjct + "") != -1
          ) {
            this.showcourseware = false;
          } else {
            this.showcourseware = true;
          }
        }
        this.getQuest(this.subjct, item.gz);
        this.start_time = item.start_time;

        this.interval = item.interval;
        // this.score = item.score
        // this.score_current = item.score_current
        this.cfs = item.exam_type;
        // this.process = item.process
        setGZ(item.gz);

        this.gz = item.gz;
        let gzlist = [
          "一般工贸",
          "职业卫生",
          "交通运输",
          "全员培训",
          "企业内训",
        ];
        await userlearn({ applyid: item.applyid }).then((res) => {
          if (res.code == 200) {
            this.score_current = res.data.score_current;
            this.aim_score = res.data.aim_score;
            this.process = res.data.process;
            this.inforMi = JSON.parse(JSON.stringify(res.data));
            this.dengjiList =
              res.data.badjb && JSON.parse(res.data.badjb)
                ? JSON.parse(res.data.badjb)
                : {};
            this.lunwenList = res.data.paper ? JSON.parse(res.data.paper) : [];
            this.exam_count =
              item.gz == "一般工贸" || item.gz == "职业卫生"
                ? res.data.exam_count_left
                : res.data.mock_count_left;
            if (!this.exam_count) {
              this.exam_count = 0;
            }
            let eee = JSON.parse(JSON.stringify(item));
            setcurrentInfo(
              JSON.stringify(
                Object.assign(eee, res.data, {
                  score_loglist: {},
                  grade_info: {},
                })
              )
            );
            setLearnTime(this.process);
            if (res.data.face_recog == "是") {
              if (isfaceMack && isfaceMack[item.gz]) {
                setisphoto(isfaceMack[item.gz]);
              }
            } else {
              delisphoto();
            }
            if (getuserstate() && getuserstate() != "undefined") {
              if (JSON.parse(getuserstate()).applyid != item.applyid) {
                deluserstate();
              }
              if (
                res.data.apply_audit_result.audit_state !=
                JSON.parse(getuserstate()).audit_state
              ) {
                deluserstate();
              }
            }
            if (
              res.data.apply_audit_result &&
              (!getuserstate() || getuserstate() == "undefined")
            ) {
              let str = "";
              if (res.data.apply_audit_result.audit_state == "审核通过") {
                str = `您的个人信息已经审核通过,请到'个人信息'菜单处下载打印您的登记表`;
              } else if (
                res.data.apply_audit_result.audit_state == "审核不通过"
              ) {
                str = `您的个人信息审核未通过,请到'个人信息'菜单处修改您的个人信息并提交`;
              }
              this.$alert(str, "个人信息修改提醒", {
                confirmButtonText: "确定",
                showClose: false,
                callback: (action) => {
                  setuserstate(
                    JSON.stringify(
                      Object.assign(res.data.apply_audit_result, {
                        attachment: res.data.attachment,
                      })
                    )
                  );
                },
              });
            }
            setispay({
              is_pay: res.data.is_pay,
              test_pay: item.gz == "特种作业" ? res.data.test_pay : "是",
            });
            this.alertMsg();
            if (gzlist.indexOf(item.gz) != -1) {
              if (
                this.aim_score <= this.score_current &&
                item.exam_passit == "不及格"
              ) {
                this.title = `您的线上培训学习时长已达到${this.aim_score}学时，可以参加正式考试`;
              } else if (
                this.aim_score <= this.score_current &&
                item.exam_passit == "及格"
              ) {
                this.title = `您已通过正式考试，完成本次培训`;
              }
            } else {
              this.title = `您的线上培训学习时长已达到${this.aim_score}学时`;
            }
            if (isfaceMack && isfaceMack[res.data.gz]) {
              if (
                isfaceMack[res.data.gz].kjface != "关闭" ||
                isfaceMack[res.data.gz].mkface != "关闭" ||
                isfaceMack[res.data.gz].zsface != "关闭" ||
                isfaceMack[res.data.gz].zxface != "关闭"
              ) {
                if (!res.data.face && res.data.face_recog == "是") {
                  let ispay = JSON.parse(getispay());
                  if (
                    (this.initObj.wxpay == "是" && ispay.is_pay == 1) ||
                    this.initObj.wxpay != "是"
                  ) {
                    getUserMedia().then((UserMedia) => {
                      if (UserMedia) {
                        this.$router.push("/face?desFace=1");
                      } else {
                        this.$message.error(
                          "该电脑没有摄像头，无法录入人脸底片"
                        );
                      }
                    });
                  }
                }
              }
            }
          }
        });
      }
    });
    if (this.http.includes("hongjing")) {
      if (this.gz == "特种作业") {
        this.list = [
          {
            lebel: "情况说明",
            url: "https://hongjing.taijieyun.com/storage/userimage/hongjing/20230417/dcc872202e0b4612c220273753245f7a.pdf",
          },
          {
            lebel: "申请表",
            url: "",
            domId: "model_a",
          },
        ];
      } else if (this.gz == "安全管理") {
        this.list = [
          {
            lebel: "工作证明",
            url: "https://hongjing.taijieyun.com/storage/userimage/hongjing/20230417/7bc54e6b1241378603b446d7c31cca79.pdf",
          },
          {
            lebel: "申请表",
            url: "",
            domId: "model_b",
          },
        ];
      }
    }
    // this.process = this.userinfor[0].process
    // this.getQuest(this.subjct,this.gz)
    // console.log(this.listhas,'121211')
    if (this.process == 100) {
      this.progressVisible = true;
    }
  },
  methods: {
    getinvoice() {
      this.$refs.applyinvoice.open(this.gz);
    },
    alertMsg(gz) {
      // console.log(this.inforMi,'555');
      // let str = '<p style="margin: 0;width: 100%;text-align: start;">各位学员：</p><p style="text-indent:28px;text-align: justify;margin: 0;">为进一步做好特种设备作业人员培训工作，现已对电梯、起重、锅炉司炉、非金属焊接、气瓶充装、快开门压力容器实操考试题库进行更新，新题库2022年7月19日启用，点击首页实操选学按钮即可进行学习。</p> <p style="text-align: end;margin: 0;">特此告知。</p>'
      if (
        (getsubject_id() == "472" || !this.inforMi.company) &&
        !this.qyType("hzdpx")
      ) {
        this.showdio = true;
      }
      if (!this.qyType("testtjy")) {
        this.showdio = false;
      }
    },
    commitEdit() {
      if (!this.radioEdit) {
        return this.$message.error("所选科目不能为空");
      }
      if (!this.company) {
        return this.$message.error("所在公司不能为空");
      }
      changesid({
        applyid: getapplyid(),
        subject_id: this.radioEdit,
        company: this.company,
      }).then((res) => {
        if (res.code == 200) {
          this.$message.success("操作成功");
          location.reload();
          // this.$store.dispatch('user/userInfo')
        } else {
          this.$message.error("操作失败");
        }
      });
    },
    async command(command) {
      // console.log(123,command);

      setsubjectTitle(command.subjectTitle);
      setsubject_id(command.subject_id);
      setapplyid(command.applyid);
      setGZ(command.gz);
      this.gz = command.gz;
      getQcount({
        subjectid: command.subject_id,
        pool: "精选题库",
        applyid: getapplyid(),
      }).then((res) => {
        if (res.code == 200) {
          if (res.data.count > 0) {
            this.isShowJX = true;
          } else {
            this.isShowJX = false;
          }
        }
      });
      let isfaceMack = "";
      if (this.initObj.is_face) {
        isfaceMack = JSON.parse(this.initObj.is_face);
      } else {
        isfaceMack = "";
      }
      // if(isfaceMack&&isfaceMack[command.gz]){
      //   setisphoto(isfaceMack[command.gz])
      // }
      this.subjct = command.subject_id;
      this.subjectTitleA = command.subjectTitle;
      this.start_time = command.start_time;

      this.interval = command.interval;
      // this.score = command.score
      // this.process = command.process
      this.cfs = command.exam_type;
      // if(command.gz=='一般工贸'||command.gz=='职业卫生'){
      //   this.zsIsYes=true
      //   this.$router.options.routes.map(item=>{
      //     if(item.name=='simulation'){
      //       item.children[0].meta.title='正式考试'
      //     }
      //   })
      // }else{
      //   this.zsIsYes=false
      //   this.$router.options.routes.map(item=>{
      //     if(item.name=='simulation'){
      //       item.children[0].meta.title='模拟考试'
      //     }
      //   })
      // }
      this.showcourseware = false;
      let exclude_material = command.exclude_material;
      if (exclude_material == "是") {
        this.showcourseware = false;
      } else {
        if (
          this.initObj.exclude_material &&
          this.initObj.exclude_material.split(",").indexOf(this.subjct + "") !=
            -1
        ) {
          this.showcourseware = false;
        } else {
          this.$nextTick(() => {
            this.showcourseware = true;
          });
        }
      }
      this.getQuest(this.subjct, command.gz);
      let gzlist = ["一般工贸", "职业卫生", "交通运输", "全员培训", "企业内训"];
      await userlearn({ applyid: command.applyid }).then((res) => {
        if (res.code == 200) {
          this.score_current = res.data.score_current;
          this.aim_score = res.data.aim_score;
          this.process = res.data.process;
          this.inforMi = JSON.parse(JSON.stringify(res.data));
          this.dengjiList =
            res.data.badjb && JSON.parse(res.data.badjb)
              ? JSON.parse(res.data.badjb)
              : {};
          this.lunwenList = res.data.paper ? JSON.parse(res.data.paper) : [];
          this.exam_count =
            command.gz == "一般工贸" || command.gz == "职业卫生"
              ? res.data.exam_count_left
              : res.data.mock_count_left;
          if (!this.exam_count) {
            this.exam_count = 0;
          }
          setLearnTime(this.process);
          let eee = JSON.parse(JSON.stringify(command));
          setcurrentInfo(
            JSON.stringify(
              Object.assign(eee, res.data, {
                score_loglist: {},
                grade_info: {},
              })
            )
          );
          setispay({
            is_pay: res.data.is_pay,
            test_pay: command.gz == "特种作业" ? res.data.test_pay : "是",
          });

          if (getuserstate() && getuserstate() != "undefined") {
            if (JSON.parse(getuserstate()).applyid != command.applyid) {
              deluserstate();
            } else {
              if (
                res.data.apply_audit_result.audit_state !=
                JSON.parse(getuserstate()).audit_state
              ) {
                deluserstate();
              }
            }
          }
          if (
            res.data.apply_audit_result &&
            (!getuserstate() || getuserstate() == "undefined")
          ) {
            let str = "";
            if (res.data.apply_audit_result.audit_state == "审核通过") {
              str = `您的个人信息已经审核通过,请到'个人信息'菜单处下载打印您的登记表`;
            } else if (
              res.data.apply_audit_result.audit_state == "审核不通过"
            ) {
              str = `您的个人信息审核未通过,请到'个人信息'菜单处修改您的个人信息并提交`;
            }
            this.$alert(str, "个人信息修改提醒", {
              confirmButtonText: "确定",
              showClose: false,
              callback: (action) => {
                setuserstate(
                  JSON.stringify(
                    Object.assign(res.data.apply_audit_result, {
                      attachment: res.data.attachment,
                    })
                  )
                );
              },
            });
          }
          if (res.data.face_recog == "是") {
            if (isfaceMack && isfaceMack[command.gz]) {
              setisphoto(isfaceMack[command.gz]);
            }
          } else {
            delisphoto();
          }
          this.alertMsg();
          if (gzlist.indexOf(command.gz)) {
            if (
              this.aim_score == this.score_current &&
              command.exam_passit == "不及格"
            ) {
              this.title = `您的线上培训学习时长已达到${this.aim_score}学时，可以参加正式考试`;
            } else if (
              this.aim_score == this.score_current &&
              command.exam_passit == "及格"
            ) {
              this.title = `您已通过正式考试，完成本次培训`;
            }
          } else {
            this.title = `您的线上培训学习时长已达到${this.aim_score}学时`;
          }
          if (isfaceMack && isfaceMack[res.data.gz]) {
            if (
              isfaceMack[res.data.gz].kjface != "关闭" ||
              isfaceMack[res.data.gz].mkface != "关闭" ||
              isfaceMack[res.data.gz].zsface != "关闭" ||
              isfaceMack[res.data.gz].zxface != "关闭"
            ) {
              getUserMedia().then((UserMedia) => {
                if (UserMedia) {
                  if (!res.data.face && res.data.face_recog == "是") {
                    let ispay = JSON.parse(getispay());
                    if (
                      (this.initObj.wxpay == "是" && ispay.is_pay == 1) ||
                      this.initObj.wxpay != "是"
                    ) {
                      this.$router.push("/face?desFace=1");
                    }
                  }
                } else {
                  this.$message.error("该电脑没有摄像头，无法录入人脸底片");
                }
              });
            }
          }
        }
      });
    },
    seachLeng() {
      userlearn({ applyid: getapplyid() }).then((res) => {
        if (res.code == 200) {
          this.dengjiList = res.data.badjb ? JSON.parse(res.data.badjb) : {};
          this.lunwenList = res.data.paper ? JSON.parse(res.data.paper) : [];
        }
      });
    },
    //我的错题
    mineError() {
      mywrong({ subjectid: getsubject_id() }).then((res) => {
        if (res.code == 200) {
          if (res.data.length <= 0) {
            this.$message.error("您还没有错题记录,快去练习吧");
          } else {
            this.$store.commit("SET_TI", res.data);
            this.$router.push(
              "/simulationExam?daan=显示" +
                "&usererror=错题集" +
                "&jrType=ctks&subjectid=" +
                getsubject_id()
            );
          }
        }
      });
    },
    //我的收藏
    mineCanlt() {
      mycollect({ subjectid: getsubject_id() }).then((res) => {
        if (res.code == 200) {
          if (res.data.length <= 0) {
            this.$message.error("您还没有收藏试题,快去收藏吧");
          } else {
            this.$store.commit("SET_TI", res.data);
            this.$router.push(
              "/simulationExam?daan=显示" +
                "&usererror=收藏" +
                "&jrType=scsj&subjectid=" +
                getsubject_id()
            );
          }
        }
      });
    },
    //特殊模块权限
    async getQuest(subjectid, gz) {
      await getSetting({ subjectid: subjectid, gz: gz }).then((res) => {
        if (res.code == 200) {
          let obj = res.data;
          let arr = ["初级", "中级", "高级", "技师"];
          this.$store.dispatch("user/commitJurisdictions", res.data);
          if (
            gz == "职业技能等级认定" &&
            (this.http.indexOf("qdjsxy") != -1 ||
              this.http.indexOf("qiye") != -1 ||
              this.http.indexOf("testtjy") != -1)
          ) {
            arr.map((item) => {
              if (this.subjectTitleA.indexOf(item) != -1) {
                this.$store.dispatch("user/commitJurisdiction", {
                  模拟考试: obj.模拟考试[item].模块展示,
                  正式考试: obj.正式考试[item].模块展示,
                  专项练习: obj.专项练习.模块展示,
                  课程学习: this.showcourseware,
                });
                this.obj = res.data.模拟考试[item];
              }
            });
          } else {
            this.$store.dispatch("user/commitJurisdiction", {
              模拟考试: obj.模拟考试.模块展示,
              正式考试: obj.正式考试.模块展示,
              专项练习: obj.专项练习.模块展示,
              课程学习: this.showcourseware,
            });
            this.obj = res.data.模拟考试;
          }
          setExectSetting(Object.assign(this.obj, { 考试类型: "模拟考试" }));
          // if(obj.模拟考试.模块展示=='显示'&&obj.正式考试.模块展示=='显示'&&obj.专项练习.模块展示=='显示'){
          // }else if(obj.模拟考试.模块展示=='显示'){
          //   this.$store.dispatch('user/commitJurisdiction','1')
          // }else if(obj.正式考试.模块展示=='显示'){
          //   this.$store.dispatch('user/commitJurisdiction','2')
          // }else
          // if(obj.专项练习.模块展示=='显示'){
          //   this.$store.dispatch('user/commitJurisdiction','0')
          // }
        }
        // const routerzswhite = ['一般工贸','职业卫生','交通运输','全员培训','企业内训']
        // if(routerzswhite.indexOf(gz)!=-1){
        //   setJurisdiction('2')
        //   this.passNum=2
        // }else{
        //   setJurisdiction('1')
        //   this.passNum=1
        // }
      });
    },
    //打印证书
    async openClick() {
      if (this.process < 100) {
        return this.$message.error("学时不足,不能打印证书!");
      }
      if (
        this.inforMi.exam_passit != "及格" &&
        (this.inforMi.gz == "一般工贸" || this.inforMi.gz == "职业卫生") &&
        getUsername() != "372924199607068671" &&
        this.http.includes("ataq")
      ) {
        return this.$message.error("考试未通过或未参加考试，不能打印证书!");
      }

      if (this.inforMi.mock_passit != "及格" && this.http.includes("ycjg")) {
        return this.$message.error("考试未通过或未参加考试，不能打印证书!");
      }
      if (!this.inforMi.cert_pdf_link.includes("http")) {
        if (!this.inforMi.cert_pdf_link) {
          return this.$message.error("暂未生成证书,请联系管理员生成!");
        } else {
          return this.$message.error(
            "无法打印证书原因:" + this.inforMi.cert_pdf_link
          );
        }
      }
      download(this.inforMi.cert_pdf_link, `${this.nickname}的证书.pdf`);

      // this.inforMi.nickname = this.nickname;
      // this.inforMi.username = this.adminUserId;
      // this.inforMi.gender = getGender();
      // this.$refs.modelPDF.open(this.inforMi);
      // await materialkmlist({
      //   msid:getsubject_id(),
      //   applyid: getapplyid(),
      //   cate: '理论',
      // }).then((res)=>{
      //   if(res.code==200){
      //     this.inforMi.score_loglist=res.data?res.data:[]
      //     this.inforMi.nickname = this.nickname
      //     this.inforMi.username = this.adminUserId
      //   }
      // })
    },
    //学员公告
    studentfont() {
      if (!this.initObj.aboutus) return this.$message.error("暂无公告通知");
      this.$alert(this.initObj.aboutus, "学员公告", {
        confirmButtonText: "确定",
        dangerouslyUseHTMLString: true,
      });
    },
    examSubmit() {
      this.$confirm(
        "请确认您已完成线上理论学时,模拟考试成绩3次超过85分后可以自行申请参加考试",
        "提醒",
        {
          confirmButtonText: "确认",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(() => {
          updateApply({ applyid: getapplyid(), apply_exam: 1 }).then((res) => {
            if (res.code == 200) {
              this.$message.success(res.msg);
            } else {
              this.$message.error(res.msg);
            }
          });
        })
        .catch();
    },
    //备案登记表
    baList() {
      console.log(this.dengjiList);
      this.$refs.modelBA.open(this.dengjiList);
    },
    //论文上传
    openUpload() {
      this.$refs.uploadFiles.open(this.lunwenList);
    },
    downloadFile(data) {
      if (data.url) {
        // let MicroMessenger = navigator.userAgent.match(/MicroMessenger/i);
        // if (MicroMessenger) {
        //     this.TCshow = true;
        //     this.downloadURL = data.url;
        // } else {
        // }
        download(data.url, data.lebel);
      } else {
        this.$nextTick(() => {
          downImg(data.lebel, data.domId).then((res) => {
            this.downloadURL = res;
          });
        });
      }
    },
    learnOpen(row) {
      this.$router.push({
        name: "curriculumindex",
        params: row,
      });
    },
  },
  mounted() {
    // if (this.showcourseware) {
    //   this.$refs.courseware.changesubjct(this.subjct);
    // }
  },
};
</script>

<style lang="scss">
</style>
<style lang="scss" scoped>
p {
  margin: 0;
}
@import "~@/styles/utis.scss";

.app-containerA {
  font-family: "Microsoft YaHei" !important;
  height: calc(100vh - 50px);
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow: auto;
  position: relative;
  width: 1740px;
  .leftbox {
    width: 100%;
    height: 294px;
    min-width: 352px;
    display: flex;
    justify-content: space-between;
    // flex-direction: column;
    .fristitem {
      padding: 18px 24px;
      background: #fff;
      height: 150px;
      display: flex;
      border-radius: 10px;
      // align-items: center;
      flex-direction: column;
      &::v-deep {
        .dropdownBox {
          width: 100%;
          margin-top: 12px;
          cursor: pointer;
          .el-dropdown-link {
            display: flex;
            justify-content: space-between;
            width: 100%;
            font-size: 16px;
            font-weight: 600;
            color: #175dff;
            align-items: center;
            line-height: 22px;
            //   \e6df
            i {
              // display: flex;
              // align-content: center;
              height: 16px;
              &::before {
                content: "\e6df";
              }
            }
          }
        }
      }
      .tipsubjet {
        height: 36px;
        width: 100%;
        background: rgba(22, 94, 255, 0.06);
        color: rgba(22, 94, 255, 1);
        display: flex;
        align-items: center;
        justify-content: flex-start;
        margin-top: 10px;
        padding-left: 24px;
        border-radius: 8px;
      }
    }
    .lastitem {
      border-radius: 10px;
      background: #fff;
      width: 674px;
      height: 100%;
      // display: flex;
      padding: 20px 24px;
      .nameAndPick {
        display: flex;
        align-items: center;
        width: 100%;
        img {
          height: 48px;
          width: 48px;
          border-radius: 18px;
          margin-right: 12px;
        }
        span {
          color: #181818;
          font-size: 14px;
          display: inline-block;
          line-height: 19px;
        }
      }

      .userInfor {
        padding: 18px 0;
        border-bottom: 1px solid #eee;
        display: flex;
        // flex-direction: column;
        justify-content: space-between;
        height: 169px;
        li {
          display: flex;
          flex-direction: column;
          justify-content: space-between;
          height: 100%;
          div {
            display: flex;
            flex-direction: column;
            span {
              color: #999999;
              font-size: 13px;
              margin-bottom: 14px;
              display: inline-block;
            }
            i {
              font-weight: 666;
              font-size: 16px;
              font-family: "DIN Alternate Bold";
            }
          }
        }
      }
    }
    .pickBox {
      border-radius: 10px;
      // padding: 20px 24px ;
      background: #fff;
      height: 100%;
      width: 508px;
      display: flex;
      flex-direction: column;
      p {
        // margin-bottom: 8px;
        color: #333;
        font-size: 16px;
      }
      .bigbox {
        flex: 1;
        overflow: auto;
        overflow-x: hidden;
        display: flex;
        flex-wrap: wrap;
        width: 100%;

        padding-bottom: 20px;
        // &::-webkit-scrollbar{
        //   width:5px;
        //   // height:5px;
        // }
        // justify-content: space-between;
        .pickItem {
          // width: 64px;
          // height: 64px;
          display: flex;
          justify-content: center;
          width: 25%;
          margin-top: 20px;
          .pickItemLi {
            cursor: pointer;
            height: 100%;
            img {
              height: 64px;
              width: 64px;
            }
            span {
              margin-top: 10px;
              font-size: 14px;
              display: block;
              text-align: center;
            }
          }
          // &:hover{
          //   background: #eee;
          //   border-radius: 5px;
          // }
        }
      }
      img {
        width: 40px;
        height: 40px;
      }
    }
    .btn_box {
      display: flex;
      flex-wrap: wrap;
      // justify-content: space-between;
      width: 100%;
      margin-top: 20px;
      .el-button {
        // margin: 0;
        // margin-top: 16px;
        // margin-bottom: 18px;
        background: rgba(241, 245, 255, 1);
        border-color: rgba(241, 245, 255, 1);
        color: #175dff;
        font-weight: 600;
        padding: 0;
        width: 92px;
        height: 40px !important;
        line-height: 40px;
        text-align: center;
        font-size: 14px;
      }
      .el-button + .el-button {
        margin-left: 22px;
      }
      // span{
      //   margin-left:38px;
      // }
      // :nth-child(1),:nth-child(4){
      //   margin-left:0;
      // }
    }
  }
  .rightbox {
    flex: 1;
    // min-width: 800px;
    background: #fff;
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    border-radius: 10px;
    .learnbox {
      // display: none;
      margin-top: 16px;
      padding: 18px 24px;
      background: #fff;
      // width: 100%;
      flex: 1;
    }
  }
}

::v-deep {
  .el-radio__input {
    display: none !important;
  }
  .el-input--medium input {
    width: 100% !important;
  }
  .elDialog {
    .el-radio__input {
      display: inline-block !important;
    }
  }
}
.item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  p {
    flex: 2;
    text-align: center;
  }
  div {
    flex: 1;
    text-align: center;
  }
}
.border {
  border-bottom: 1px solid #ccc;
}
</style>
